package com.yaoli.niuke;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created by will on 2017/5/10.
 */
public class _013_Test {
    public static void main(String[] args) {
        _013_Test test = new _013_Test();

        int nusm [] = {3,5,1,13,2};

        test.PrintMinNumber(nusm);


    }

    public String PrintMinNumber(int [] numbers) {
        if(numbers == null || numbers.length == 0) return "";
        int len = numbers.length;
        String[] str = new String[len];
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < len; i++){
            str[i] = String.valueOf(numbers[i]);
        }
        Arrays.sort(str,new Comparator<String>(){
            @Override
            public int compare(String s1, String s2) {
                String c1 = s1 + s2;
                String c2 = s2 + s1;
                return c1.compareTo(c2);
            }
        });
        for(int i = 0; i < len; i++){
            sb.append(str[i]);
        }
        return sb.toString();
    }
//    public int GetNumberOfK(int [] array , int k) {
//
//        boolean flag = false;
//        int count = 0;
//        for(int i = 0 ; i < array.length ; i++){
//            if(array[i] == k){
//                count++;
//                flag = true;
//            }else if(array[i] != k && flag = true){
//                break;
//            }
//        }
//
//        return count;
//    }
}
